<?php
/**
 * Created by PhpStorm.
 * User: 火柴
 * Date: 2016/5/15
 * GitHub: https://github.com/huaiguoguo
 * Email: 290559038@qq.com
 * Time: 19:06
 */


namespace common\models;

use yii\base\Model;
use yii\web\UploadedFile;

/**
 * UploadForm is the model behind the upload form.
 */
class UploadForm extends Model
{
    /**
     * @var UploadedFile file attribute
     */
    public $file;

    /**
     * @return array the validation rules.
     */
    public function rules()
    {
        return [
            [['file'], 'file',
                'extensions' => ['jpg', 'png', 'jpeg'],
                'wrongExtension' => '只能上传{extensions}类型文件！',
                'mimeTypes' => 'image/jpeg, image/png',
                'maxSize' => 1024 * 1024 * 2, 'tooBig' => '文件上传过大!',
                'skipOnEmpty' => false, 'uploadRequired' => '请上传文件!',
            ]
        ];
    }
}